<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="url" value="${pageContext.request.contextPath}/" />
<script type="text/javascript">
function submitAddNewNodeAction(){
	$.ajax({
		cache:false,
		async:false,
		type:"POST",
		url: path
		+"local/addNewNode",
		data:$('#addNewNodeAction').serialize(),
		success: function(result){
			if(result){
				alert("添加成功");
				$('#myModal').modal('hide');
				$('.modal-backdrop').removeClass('in');
				init();
			}else{
				alert("添加失败");
				$('.modal-backdrop').removeClass('in');
				$('#myModal').modal('hide');
			}
		}
	});
}
</script>
<div class="box box-primary">
  <!-- /.box-header -->
  <div class="box-body no-padding">
    <div class="table-responsive mailbox-messages">
      <table class="table table-bordered table-hover">
      	<thead>
      		<tr style="background-color: #f9f9f9;">
      		<th>主机名</th>
      		<th>IP</th>
      		<th>状态</th>
      		<th>负载</th>
      		<th>服务</th>
      		<th>操作</th>
      		</tr>
      	</thead>
        <tbody id="serviceTbody">
        </tbody>
      </table>
      <!-- /.table -->
    </div>
    <!-- /.mail-box-messages -->
  </div>
  <!-- /.box-body -->
  
</div>
<div class="box box-primary">
  <div class="box-header with-border">
    <h3 class="box-title">空闲节点</h3>
    <!-- /.box-tools -->
  </div>
  <!-- /.box-header -->
  <div class="box-body no-padding">
  	<div class="mailbox-controls">
      <div class="btn-group">
        <button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#myModal"><i class="fa fa-plus"></i>添加空闲节点</button>
      </div>
    </div>
    <div class="table-responsive mailbox-messages">
      <table class="table table-bordered table-hover">
      	<thead>
      		<tr style="background-color: #f9f9f9;">
      		<th>主机名</th>
      		<th>IP</th>
      		<th>状态</th>
      		<th>负载</th>
      		<th>服务</th>
      		<th>操作</th>
      		</tr>
      	</thead>
        <tbody id="addserviceTbody">
        
        </tbody>
      </table>
      <!-- /.table -->
    </div>
    <!-- /.mail-box-messages -->
  </div>
  <!-- /.box-body -->
  <input id="localId" type="hidden" value="${localId }">
</div>
<!-- 模态框（Modal） -->
 <form id="addNewNodeAction">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <h4 class="modal-title" id="myModalLabel">
               添加空闲节点
            </h4>
         </div>
         <div class="modal-body">
             <div class="form-group">
			      <label for="name">IP</label>
			      <input type="text" class="form-control" id="ip" name="ip" 
			         placeholder="请输入ip">
   			</div>
   			<div class="form-group">
			      <label for="name">主机</label>
			      <input type="text" class="form-control" id="hostname" name="os" 
			         placeholder="请输入主机">
   			</div>
         </div>
         <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal">关闭
            </button>
            <button type="button" class="btn btn-primary" onclick="submitAddNewNodeAction()">
               提交
            </button>
         </div>
      </div><!-- /.modal-content -->
   </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</form>
<script type="text/javascript">
	function toNode(id){
		linkByDom('serverInfo','${url }local/info?localId='+id+'&nodeIp='+$("#nodeIp").val());
		$('#jspInclude').remove();
		$('#nav-tabs-custom').show();
	}
	
	function toNodeIndex(id,item){
		$("#nodeIp").val(item);
		linkByDom('serverInfo','${url }local/info?localId='+id+'&nodeIp='+$("#nodeIp").val());
		$('#jspInclude').remove();
		$('#nav-tabs-custom').show();
	}
</script>